<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title>构造方法和析钩方法的练习</title>
</head>
<body>
<?php 

/**
*构造方法做成员初始化的工作，当创建一个对象时候，构造方法就会自动调用一次
析钩方法是在销毁一个对象前执行的一些特定操作
*/
class Person 
{

	var $name;
	var $age;
	var $sex;
	function __construct($name,$age,$sex){
    $this->name=$name;
     $this->age=$age;
      $this->sex=$sex;

	}
	function __destruct(){
		echo "goodby:".$this->name."<br>";
	}
	function say(){
		echo "我的姓名是".$this->name;
		echo "我的年龄是".$this->age;
		echo "我的性别是".$this->sex."<br>";

	}
	function eat(){
			echo "这个人在吃"."<br>";


	}
	function run(){
			echo "这个人在跑"."<br>";


	}
}
	$p1=new Person("zhangsan","1","boy");
	
	$p2=new Person("lisi","43","gril");
	$p3=new Person("laowang","20","gril");
	$p1->say();
	$p1=null;
	$p2->say();
	$p3->say();
	

	
	/*function __construct(argument)
	{
		# code...
	}*/

 ?>

</body>
</html>

